package com.tsunami.authority.entity.auth;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tsunami.base.entity.SuperEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDateTime;

/**
 * <p>
 * 用户角色表
 * </p>
 *
 * @author lx
 * @since 2021-09-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@TableName("tnm_auth_user_role")
@Schema(description = "用户角色")
public class UserRole extends SuperEntity<Long> {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "租户号")
    @TableField(value = "tenant_id")
    private Long tenantId;

    @Schema(description = "角色ID")
    @TableField(value = "role_id")
    private Long roleId;

    @Schema(description = "用户ID")
    @TableField(value = "user_id")
    private Long userId;

    @Schema(description = "应用编码")
    @TableField(value = "app_code")
    private String appCode;

    @Builder
    public UserRole(Long id, Long createUser, LocalDateTime createTime,
                    Long roleId, Long userId, String appCode) {
        this.id = id;
        this.createUser = createUser;
        this.createTime = createTime;
        this.roleId = roleId;
        this.userId = userId;
        this.appCode = appCode;
    }
}
